calculate Scaled Dp Compose
EN Shared pure-math scaling kernel used by toDynamicScaledDp and toDynamicScaledPx.
Algorithm summary:
Applies Inverter rules to swap the effective DpQualifier based on orientation.
If ignoreMultiWindows is
true, detects split-screen via layout flags; if active, returns baseValue unchanged so the UI does not over-scale in a small window.For the common path (
SMALL_WIDTH+DEFAULTinverter + no custom sensitivity), delegates to DimenCache.calculateRawScaling which reads the pre-computed factors from DimenCache.ScreenFactors — one float multiply, zero extra allocations.For other qualifiers or custom sensitivity, reads the screen dimension from Configuration and performs the scaling formula inline.
Performance: Simple paths without Aspect Ratio complete in ~2 ns (single multiply). Paths with Aspect Ratio require ~41 ns on Snapdragon 888 (includes ln() fallback). Results are memoized by the surrounding remember block and DimenCache.
PT Núcleo de escalonamento puro compartilhado por toDynamicScaledDp e toDynamicScaledPx.
Resumo do algoritmo:
Aplica as regras de Inverter para trocar o DpQualifier efetivo conforme a orientação.
Se ignoreMultiWindows for
true, detecta split-screen via flags de layout; se ativo, retorna baseValue sem escalar.Para o caminho comum (SMALL_WIDTH + DEFAULT + sem sensibilidade customizada), delega para DimenCache.calculateRawScaling com os fatores pré-calculados.
Para outros qualificadores ou sensibilidade customizada, lê a dimensão da tela do Configuration e executa a fórmula de escalonamento inline.
Return
Scaled Dp value as a raw Float (caller converts to Dp or pixels).
Parameters
Raw Dp value to scale (e.g. 16f for 16 dp).
Current Configuration snapshot from LocalConfiguration.current.
Original screen qualifier before inversion.
Orientation-swap rule.
Whether to suppress scaling in multi-window mode.
Whether to apply the AR multiplier.
Custom AR sensitivity constant, or null for the library default.